<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>提现管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/activity/member_act_list.css">
    <%@include file="../include/commonFile.jsp" %>
    <style type="text/css">
        .layui-table[lay-size=sm] td, .layui-table[lay-size=sm] th {
            font-size: 13px;
            padding: 9px 10px;
        }
    </style>
</head><body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/wallet/withdrawals/withdrawalList.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">单号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="orderNum" autocomplete="off" class="layui-input"
                                           value="${withdrawal.orderNum}" placeholder="请输入查询提现单号">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">提现者</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="memberName" autocomplete="off" class="layui-input"
                                           value="${input.memberName}" placeholder="请输入查询提现者">
                                </div>
                            </li>
                            <c:if test="${withdrawal.type == 4}">
                                <li class="form-item-inline"><label class="search-form-lable">主题名称</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="eventName" autocomplete="off" class="layui-input"
                                               value="${withdrawal.eventName}" placeholder="请输入查询主题名称">
                                    </div>
                                </li>
                            </c:if>
                            <li class="form-item-inline"><label class="search-form-lable">审核状态</label>
                                <div class="layui-input-inline">
                                    <select name="status">
                                        <option value="">全部</option>
                                        <c:forEach var="map" items="${checkStatus}">
                                            <c:if test="${withdrawal.status == map.key}">
                                                <option value="${map.key}" selected="selected">${map.value}</option>
                                            </c:if>
                                            <c:if test="${withdrawal.status != map.key}">
                                                <option value="${map.key}">${map.value}</option>
                                            </c:if>
                                        </c:forEach>
                                    </select>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">提现类型</label>
                                <div class="check-btn-inner" id="type">
                                    <a id="allType" href="javascript:void(0);" onclick="setTimeType($(this),0,'#myForm')" ${empty withdrawal.type || withdrawal.type == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),5,'#myForm')" ${withdrawal.type == 5 ? 'class="active"' : ''}>活动</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),2,'#myForm')" ${withdrawal.type == 2 ? 'class="active"' : ''}>佣金</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),4,'#myForm')" ${withdrawal.type == 4 ? 'class="active"' : ''}>众筹</a>
                                    <a href="javascript:void(0);" onclick="setTimeType($(this),3,'#myForm')" ${withdrawal.type == 3 ? 'class="active"' : ''}>商城分销</a>
                                    <input type="hidden" name="type" value="${withdrawal.type}"/>
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a> <a
                                        class="layui-btn layui-btn-normal"
                                        href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">提现时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}"
                                               placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}"
                                               placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="my-act-list-content">
                <ul class="num">
                    <div class="l">
                        <li class="f16">提现次数<span class="red">${page.totalCount}</span>次</li>
                    </div>
                    <div class="r">
                        <li style="cursor: pointer;" class="r"><a class="layui-btn layui-btn-danger layui-btn-sm"
                                                                  id="btnExport">导出EXCEL</a></li>
                    </div>
                    <p class="cl"></p>
                </ul>
                <div class="cl">
                    <table class="layui-table" lay-skin="line" lay-size="sm" id="myTable">
                        <colgroup>
                            <col>
                            <col>
                            <c:if test="${withdrawal.type == 4}">
                                <col width="15%">
                            </c:if>
                            <col width="120px">
                            <col width="120px">
                            <col width="120px">
                            <col width="140px">
                            <col width="70px">
                            <col width="100px">
                            <col width="100px">
                            <col width="60px">
                        </colgroup>
                        <thead>
                        <tr>
                            <c:if test="${withdrawal.type == 4}">
                                <th>主题名称</th>
                            </c:if>
                            <th>单号</th>
                            <th>提现者</th>
                            <th>提现金额</th>
                            <th title="提现金额x(微信提现手续费(0.006)+平台提现手续费)">手续费<font style="color: red">*</font></th>
                            <th>实际应付</th>
                            <th>提现时间</th>
                            <th>状态</th>
                            <th>类型</th>
                            <th>操作</th>
                            <th style="text-align: center">展开</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:set var="wtype" value="${withdrawal.type}"></c:set>
                        <c:forEach var="withdrawal" items="${withdrawals}">
                            <tr class="info">
                                <c:if test="${wtype == 4}">
                                    <td>${withdrawal.eventName}</td>
                                </c:if>
                                <td>${withdrawal.orderNum}</td>
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${withdrawal.createBy}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img">
                                            <img src="<c:if test="${withdrawal.memberLogo!= null}">${withdrawal.memberLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1">
                                            <a class="blue" title="${withdrawal.memberName}" href="javascript:void(0);">${withdrawal.memberName}</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <div>¥<fmt:formatNumber pattern="0.00" value="${withdrawal.payment}"/></div>
                                </td>
                                <td>
                                    <div>¥<fmt:formatNumber pattern="0.00" value="${withdrawal.serviceFee}"/>元</div>
                                </td>
                                <td>
                                    <div>¥<fmt:formatNumber pattern="0.00" value="${withdrawal.netAmount}"/>元</div>
                                </td>
                                <td>
                                    <div><fmt:formatDate value="${withdrawal.updateDate}" pattern="yyyy-MM-dd HH:mm"/></div>
                                </td>
                                <td>
                                    <div>
                                        <c:if test="${withdrawal.status == 1}">
                                            <span>处理中</span>
                                        </c:if>
                                        <c:if test="${withdrawal.status == 2}">
                                            <span class="green">已付款</span>
                                        </c:if>
                                        <c:if test="${withdrawal.status == 3}">
                                            <span class="red">已拒绝</span>
                                        </c:if>
                                        <c:if test="${withdrawal.status == 4}">
                                            <span>已通过</span>
                                        </c:if>
                                    </div>
                                </td>
                                <td>
                                    <c:if test="${withdrawal.type == 4}">众筹</c:if>
                                    <c:if test="${withdrawal.type == 5}">活动</c:if>
                                    <c:if test="${withdrawal.type == 2}">佣金</c:if>
                                    <c:if test="${withdrawal.type == 3}">商城分销</c:if>
                                </td>
                                <td class="opts-btns tb-opts" style="width: 150px">
                                    <div class="comm-opts">
                                        <c:if test="${withdrawal.status == 1}">
                                            <a class="green" href="javascript:check('确认要审核通过该提现吗？', '${withdrawal.id}', '4')">通过</a>
                                            <a class="red" href="javascript:check('确认要审核拒绝该提现吗？', '${withdrawal.id}', '3')">拒绝</a>
                                        </c:if>
                                        <c:if test="${withdrawal.status == 4}">
                                            <a class="orange" href="javascript:check('确认要标记为已付款？', '${withdrawal.id}', '2')">付款</a>
                                        </c:if>
                                    </div>
                                </td>
                                <td>
                                    <div class="option">
                                        <i class="iconfont icon-unfold"></i>
                                        <i class="iconfont icon-fold dis-none"></i>
                                    </div>
                                </td>
                            </tr>
                            <tr class="dis-none info-detail">
                                <td colspan="10">
                                    <div>
                                        <table width="100%" class="childTable layui-table" lay-skin="row"
                                               style="margin: 0px">
                                            <tbody>
                                            <tr>
                                                <td>银行账号</td>
                                                <td>${withdrawal.accountNumber}</td>
                                            </tr>
                                            <tr>
                                                <td>开户名</td>
                                                <td>${withdrawal.name}</td>
                                            </tr>
                                            <tr>
                                                <td>预留手机号</td>
                                                <td>${withdrawal.phone}</td>
                                            </tr>
                                            <tr>
                                                <td>银行名称</td>
                                                <td>${withdrawal.bankName}</td>
                                            </tr>
                                            <tr>
                                                <td>开户行</td>
                                                <td>${withdrawal.openedPlace}</td>
                                            </tr>
                                            <tr>
                                                <td>备注</td>
                                                <td>${withdrawal.remarks}</td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
    <div id="bmDialog">
        <form class="layui-form p10" action="${ctx}/wallet/withdrawals/verify.do" id="infoForm">
            <input type="hidden" name="id" value="" />
            <input type="hidden" name="status" value="" />
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 30px;padding-left: 0px;">备注<span class="f-verify-red">*</span></label>
                <div class="layui-input-block" style="margin-left: 50px;">
                    <textarea name="remarks" lay-verify="remarks" class="layui-textarea"></textarea>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">

    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>

    function check(content, withdrawalId, checkStatus) {
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            layer.close(index);
            if (checkStatus == 2 || checkStatus == 4) {
                submitCheck(withdrawalId, checkStatus);
            } else if (checkStatus == 3) {
                reject(withdrawalId);
                function reject(targetId) {
                    var setPayIndex = layer.open({
                        type: 1,
                        area: '400px',
                        title: '填写备注信息提交',
                        content: $("#bmDialog"),
                        btn: ['确定', '取消'],
                        success: function () { // 弹出后回调
                            $("#infoForm").find("[name=remarks]").val("");
                            $("#infoForm").find("[name=id]").val(targetId);
                            $("#infoForm").find("[name=status]").val(checkStatus);
                        },
                        end: function () { // 销毁后回调
                            $("#infoForm").find("[name=remarks]").val("");
                            $("#infoForm").find("[name=id]").val("");
                            $("#infoForm").find("[name=status]").val("");
                        },
                        yes: function () { // 确定按钮
                            var remarks = $("#infoForm [name=remarks]").val();
                            if (remarks == "") {
                                util.layerMsgError("请填写备注");
                            } else {
                                var action = $("#infoForm").attr("action");
                                $.post(action, $('#infoForm').serialize(), function (res) {
                                    if (res.success) {
                                        util.layerMsgSuccess("提交成功", function () {
                                            submitFunction('#myForm');
                                        });
                                    } else {
                                        util.layerMsgError("提交失败")
                                    }
                                });
                                layer.close(setPayIndex);
                            }
                        }
                    });
                }
            }
        });
    }

    function submitCheck(withdrawalId, checkStatus) {
        $.post("${ctx}/wallet/withdrawals/verify.do", {
            id: withdrawalId,
            status: checkStatus
        }, function (data) {
            if (data.success == true) {
                util.layerMsgSuccess("审核成功", function () {
                    window.location.reload();
                })
            } else {
                util.layerMsgError("审核失败")
            }
        })
    }

    function closeDialog() {
        $(".bmDialog").fadeOut();
    }
    $(function () {

        //加载分页
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});
        layui.use(['laydate', 'form'], function () {
            var laydate = layui.laydate;
            var form = layui.form;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);

            //自定义验证规则
            form.verify({
                remarks : function(value) {
                    if (value == "") {
                        return '请填写备注';
                    }
                }
            });

            //监听提交
            form.on('submit(infoForm)', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#infoForm").attr("action");
                    $.post(action, $('#infoForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess("提交成功", function () {
                                submitFunction('#myForm');
                            });
                        } else {
                            util.layerMsgError("提交失败")
                        }
                    });
                });
                return false;
            });
        });
        $('#myTable').delegate('.option', 'click', function (e) {
            var info = $(this).closest('.info');
            if (!info.hasClass('active')) {//打开
                $('.info').removeClass('active');
                $(".info-detail").removeClass('dis-block');
                info.toggleClass('active');
                $(info).next(".info-detail").addClass('dis-block');
            } else {
                info.toggleClass('active');
                $(info).next(".info-detail").removeClass('dis-block');
            }
        });

        $("#btnExport").click(function () {
            layer.confirm('确认要导出Excel吗?', {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                var url = "${ctx}/wallet/withdrawals/exportWithdrawal.do";
                //loading层
                var loadIndex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                $.post(url, $("#myForm").serialize(), function (res) {
                    top.layer.close(loadIndex);
                    if (res.success) {
                        window.location.href = res.data;
                    } else {
                        util.layerMsgError(res.description)
                    }
                });
                top.layer.close(index);
            });
        });
    })
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '提现管理',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>'
    });
</script>
</body>
</html>